#include<iostream>
#include<gtest/gtest.h>
#include<unordered_map>

class MyTest:public testing::Test {

public:
//这里每个测试单元所需要独立的测试环境
void SetUp() override
{
    std::cout<<"单元测试初始化\n";
    dict.insert(std::make_pair("apple","苹果"));
    dict.insert(std::make_pair("peal","梨"));

}
//这里处理每个单元测试自己插入的数据
void TearDown ()override
{
    dict.clear();
    std::cout<<"单元数据的清理\n"<<std::endl;
}
 static void SetUpTestCase()
 {
    std::cout<<"所有单元格测试前执行，初始化总环境\n";

 }

static void TearDownTestCase()
{
    std::cout<<"所有单元格测试执行完毕，清理总环境\n";
}
public:
 std::unordered_map<std::string,std::string> dict;
};

TEST_F(MyTest, insert_test) {
 std::cout << "环境1,中间insert测试\n";
 dict.insert(std::make_pair("Hello", "你好"));
 dict.insert(std::make_pair("hello", "你好"));
 dict.insert(std::make_pair("雷吼", "你好"));
 auto it = dict.find("hello");
 ASSERT_NE(it, dict.end());
}

TEST_F(MyTest, dict_size) {
 std::cout << "环境1,中间size测试\n";
ASSERT_GT(dict.size(), 0);
}


//TEST_F(MyTest,insert_test)
//{
 //   _mymap.insert(std::make_pair("hello","你好"));
 //   _mymap.insert(std::make_pair("bye","再见"));

//}
//TEST_F(MyTest,size_test)
//{
// ASSERT_EQ(_mymap.size(),2);
//}

int main(int argc, char *argv[])
{
 testing::InitGoogleTest(&argc, argv);
 return RUN_ALL_TESTS();
}
